#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# @Author  : tester
# @Site    : DONGFANG_HOTEL-10F
# @Software: PyCharm
# @datetime:2020/11/7 15:58
# @license: (C) Copyright 2018-2027, By 金锡科技.
"""
import logging
import sys
import datetime


# 日志方法
def get_loggers(log_name):
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)

    # StreamHandler
    stream_handler = logging.StreamHandler(sys.stdout)
    stream_handler.setLevel(level=logging.DEBUG)
    logger.addHandler(stream_handler)

    # FileHandler
    file_handler = logging.FileHandler(log_name, encoding='utf-8')
    file_handler.setLevel(level=logging.INFO)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    return logger


# 调用日志方法
log = get_loggers(f'../logger/api_test_{datetime.datetime.now().strftime("%Y-%m-%d")}.log')
